CalculateIssuanceData

subplot(3,1,1)
bas=all;
ss=esg;
[Lia Locb]=ismember(ss.industry,bas.industry);
compesg.industry=ss.industry(Lia);
compesg.dat=zeros(sum(Lia),length(ss.years),2);
compesg.years=ss.years;
[Lia2 Locb2]=ismember(ss.years,bas.years);
compesg.dat(:,:,1)=bas.dat(Locb(Locb>0),Locb2(Locb2>0));
compesg.dat(:,:,2)=ss.dat(Lia,:);
plot(compesg.years,100*compesg.dat(4,:,2)./compesg.dat(4,:,1),'-','LineWidth',2)
ss=gb;
[Lia Locb]=ismember(ss.industry,bas.industry);
comp.industry=ss.industry(Lia);
comp.dat=zeros(sum(Lia),length(ss.years),2);
comp.years=ss.years;
[Lia2 Locb2]=ismember(ss.years,bas.years);
comp.dat(:,:,1)=bas.dat(Locb(Locb>0),Locb2(Locb2>0));
comp.dat(:,:,2)=ss.dat(Lia,:);
hold on;
plot(comp.years,100*comp.dat(6,:,2)./comp.dat(6,:,1),'--','LineWidth',2)
hold off 
ylabel('Percent of amount issued')
legend('ESG bonds','Green bonds','Location','Northwest')
title('Panel A: Corporate bonds globally')
legend('boxoff')
xlim([2012 2022])

frac=compesg.dat(:,13,2)./compesg.dat(:,13,1);
[B,I] = sort(frac,'descend');
ind=find(isfinite(B));
top_industry=I(ind);
subplot(3,1,2)
no=5;
tmp=0; i=0;
inds=zeros(no,1);
lin{1}='-'; lin{2}='--'; lin{3}='-.'; lin{4}='-x'; lin{5}='-o';
while tmp<no
    i=i+1;
    if (compesg.dat(top_industry(i),:,1)==0)==0
        tmp=tmp+1;
        inds(tmp)=top_industry(i);
        plot(compesg.years,100*compesg.dat(top_industry(i),:,2)./compesg.dat(top_industry(i),:,1),lin{tmp},'LineWidth',2)
        hold on;
    else end
end
hold off
legend(compesg.industry(inds),'Location','NorthWest')
legend('boxoff')
xlim([2012 2022])
title('Panel B: Corporate bonds, sectors globally')
ylabel('Percent of amount issued')


ind=sum((govt.datsum(:,2:7,1))'==0)==0;
country=govt.country(ind);
gb=squeeze(govt.datsum(ind,2:7,3)./govt.datsum(ind,2:7,1));
[B I]= sort(gb(:,end),'descend');
subplot(3,1,3)
cou=[1:4 9];
no=length(cou);
for i=1:no
    plot(govt.years(2:7),100*gb(I(cou(i)),:),lin{i},'LineWidth',2)
    hold on;
end
hold off
legend(country(I(cou(1:no))),'Location','NorthWest')
legend('boxoff')
xlim([2017 2022])
xticks(2017:2022)
title('Panel C: Government green bonds')
ylabel('Percent of amount issued')

